//
//  TabBarController.swift
//  XMTV
//
//  Created by 王磊 on 17/4/25.
//  Copyright © 2017年 王磊. All rights reserved.
//

import UIKit

class TabBarController: UITabBarController {

    
    override class func initialize(){
    
        var attrs = [String: NSObject]()
        attrs[NSForegroundColorAttributeName] = UIColor(r: 87, g: 206, b: 138)
        UITabBarItem.appearance().setTitleTextAttributes(attrs, for: UIControlState.selected)
        
    
    
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        addChildViewControllers()
       self.view.backgroundColor = UIColor.red
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func addChildViewControllers() {
        setupOneChildViewController(title: "首页", image: "menu_homepage_nor", seletedImage: "menu_homepage_sel", controller: HomeVC.init())
        setupOneChildViewController(title: "游戏", image: "menu_youxi_nor", seletedImage: "menu_youxi_sel", controller: GameVC.init())
        setupOneChildViewController(title: "娱乐", image: "menu_yule_nor", seletedImage: "menu_yule_sel", controller: EntertainmentVC.init())
        setupOneChildViewController(title: "小葱秀", image: "menu_goddess_nor", seletedImage: "menu_goddess_sel", controller: SmallShowVC.init())
//        setupOneChildViewController(title: "我的", image: "menu_mine_nor", seletedImage: "menu_mine_sel", controller: UIStoryboard(name: "Me", bundle: nil).instantiateInitialViewController()!)
    }
    fileprivate func  setupOneChildViewController(title: String,image: String,seletedImage: String,controller: UIViewController){
    
        controller.tabBarItem.title = title
        controller.title = title
        controller.view.backgroundColor = BGCOLOR
        controller.tabBarItem.image = UIImage.init(named: image)
        controller.tabBarItem.selectedImage = UIImage.init(named: seletedImage)
        let naviController = NavigationController.init(rootViewController: controller)
        addChildViewController(naviController)
    }

}
